package com.tushare.controller;

import com.tushare.entity.*;
import com.tushare.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")
public class WebNormController {
    private static final int TRADE_DATE = 20190101;
    @Autowired
    IDailyService dailyService;
    @Autowired
    IAnalyseService analyseService;
    @Autowired
    IHkHoldService hkHoldService;
    @Autowired
    IMarginDetailService marginDetailService;
    @Autowired
    IStkHolderNumberService holderNumberService;

    @GetMapping("loadDaily")
    public List<Daily> loadDaily(@RequestParam("ts_code") String ts_code) {
        return dailyService.getDailyListByTsCode(ts_code, TRADE_DATE);
    }

    @GetMapping("loadAnalyse")
    public List<Analyse> loadAnalyse() {
        return analyseService.getAnalyseList();
    }

    @GetMapping("loadHkHold")
    public List<HkHold> loadHkHold(@RequestParam("ts_code") String ts_code) {
        return hkHoldService.getHkHoldListByTsCode(ts_code, TRADE_DATE);
    }

    @GetMapping("loadMarginDetail")
    public List<MarginDetail> loadMarginDetail(@RequestParam("ts_code") String ts_code) {
        return marginDetailService.getTopMarginDetailList(ts_code, TRADE_DATE);
    }

    @GetMapping("loadHoldNumber")
    public List<StkHolderNumber> loadHoldNumber(@RequestParam("ts_code") String ts_code) {
        return holderNumberService.getStkHolderNumberByTsCode(ts_code, TRADE_DATE);
    }
}
